cmake_minimum_required(VERSION 3.0)

project(appfw)


if(UNDER_LINUX)
option(BUILD_LCM "" OFF)
option(BUILD_PPS "" OFF)
endif()

if(UNDER_QNX)
option(BUILD_LCM "" OFF)
option(BUILD_PPS "" ON)
endif()

if(BUILD_LCM)
add_definitions(-DDEF_BUILD_LCM)
file(GLOB appfw_add src/transport/lcm/lcm_proxy.cpp)
endif()

if(BUILD_PPS)
add_definitions(-DDEF_BUILD_PPS)
file(GLOB appfw_add src/transport/pps/pps.cpp src/transport/pps/pps_proxy.cpp)
endif()

if(UNDER_QNX)
set(iceoryx_posh_DIR ../thirdparty/qnx_aarch64/iceoryx/lib/cmake/iceoryx_posh)
set(iceoryx_hoofs_DIR ../thirdparty/qnx_aarch64/iceoryx/lib/cmake/iceoryx_hoofs)
include_directories(../thirdparty/qnx_aarch64/iceoryx/include/iceoryx/v2.0.0)
endif()

if(UNDER_LINUX)
set(iceoryx_posh_DIR ../thirdparty/linux_x86/iceoryx/lib/cmake/iceoryx_posh)
set(iceoryx_hoofs_DIR ../thirdparty/linux_x86/iceoryx/lib/cmake/iceoryx_hoofs)
include_directories(../thirdparty/linux_x86/iceoryx/include/iceoryx/v2.0.0)
endif()

find_package(iceoryx_posh CONFIG REQUIRED)
find_package(iceoryx_hoofs CONFIG REQUIRED)

include_directories(
    include
    src
    ../thirdparty/lcm/include
    )

file(GLOB appfw_SRC
    src/motovis.cpp
    src/node/node.cpp
    src/component/component.cpp
    src/transport/transport.cpp
    src/transport/iox/iox_proxy.cpp
    )

add_library(appfw_ipc SHARED ${appfw_SRC} ${appfw_add})

install(TARGETS appfw_ipc DESTINATION ${APPFW_IPC_INSTALL_LIB_DIR})
install(DIRECTORY include/common include/component include/Logger include/node src/transport DESTINATION ${APPFW_IPC_INSTALL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.h")
install(FILES include/motovis.h DESTINATION ${APPFW_IPC_INSTALL_INCLUDE_DIR})

